package com.umer.pinban.adapter.user;

import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.common.ui.recycleview.adapter.RecyclerviewBasicAdapter;
import com.common.ui.recycleview.base.ViewHolder;
import com.common.ui.recycleview.listener.OptListener;
import com.umer.pinban.R;
import com.umer.pinban.bean.user.SelectMemberListBean;
import java.util.List;

public class SelectMemberListAdapter extends RecyclerviewBasicAdapter<SelectMemberListBean> {

    private OptListener optListener;

    public SelectMemberListAdapter(Context context, List<SelectMemberListBean> datas, int layoutId,
                                   OptListener optListener) {
        super(context, datas, layoutId);
        this.optListener = optListener;
    }

    @Override
    public void convert(ViewHolder holder, final SelectMemberListBean bean, final int position) {
        LinearLayout linear_lay =  holder.getView(R.id.linear_lay);
        TextView tv1 = holder.getView(R.id.tv1);
        TextView tv2 = holder.getView(R.id.tv2);
        TextView tv3 = holder.getView(R.id.tv3);
        TextView tv4 = holder.getView(R.id.tv4);
        TextView tv5 = holder.getView(R.id.tv5);
        TextView tv6 = holder.getView(R.id.tv6);

        String remark = bean.getRemark();
        if(remark!=null && !remark.equals("null")&& !remark.equals("")&& !remark.equals(" ")){
            tv1.setText(remark);
        }else {
            tv1.setText("");
        }

        String content = bean.getContent();
        if(content!=null && !content.equals("null")&&
                !content.equals("")&& !content.equals(" ")){
            tv2.setText(content);
        }else {
            tv2.setText("");
        }

        String originalPrice = bean.getOriginalPrice();
        if(originalPrice!=null && !originalPrice.equals("null")&&
                !originalPrice.equals("")&& !originalPrice.equals(" ")){
            tv3.setText(originalPrice);
        }else {
            tv3.setText("");
        }
        // 中间加横线 ， 添加Paint.ANTI_ALIAS_FLAG是线会变得清晰去掉锯齿
        tv3.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG );

        String price = bean.getPrice();
        if(price!=null && !price.equals("null")&&
                !price.equals("")&& !price.equals(" ")){
            tv4.setText("¥"+ price);
        }else {
            tv4.setText("");
        }

        String description = bean.getDescription();
        if(description!=null && !description.equals("null")&&
                !description.equals("")&& !description.equals(" ")){
            tv5.setText(description);
        }else {
            tv5.setText("");
        }

        linear_lay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,position);
            }
        });
    }
}
